package test;

import bean.Dept;
import bean.Emp;
import mapper.EmpMapper;
import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;
import service.DeptService;
import service.EmpService;


import java.io.IOException;
import java.io.InputStream;

public class App {
    private EmpService empService;
    private DeptService deptService;
    public App(){
        empService=new EmpService();
        deptService=new DeptService();
    }
    public void a() throws IOException{
        InputStream in=Resources.getResourceAsStream("config.xml");
        SqlSessionFactory ssf= new SqlSessionFactoryBuilder().build(in);
        SqlSession session=ssf.openSession();
        EmpMapper mapper=session.getMapper(EmpMapper.class);
        Emp emp =mapper.findEmpByNo3(7960);
        System.out.println(emp);
        session.close();
    }
    public void b(){
        Emp emp=empService.findEmpByNo(7959);
        System.out.println(emp);
    }

    public void c(){
        Dept dept=deptService.find2(10);
        System.out.println(dept);
    }

    public static void main(String[] args) {
        App app=new App();
        app.c();
    }

}
